﻿//Copyright (c) 2009-2010, Andreas Grünwald
//All rights reserved.

using System;
//using yaTDL.Core.Todoist;
using System.Collections.Generic;
using System.Security;
using System.Diagnostics;

namespace yaTDL.Core
{
    /// <summary>
    /// EventArgs for events concering Tasks that contain information to identify the Task that is subject to the event.
    /// </summary>
    public class TaskEventArgs:EventArgs
    {
        
        /// <summary>
        /// Initializes a new instance of TaskEventArgs
        /// </summary>
        /// <param name="projectId">The value of the ProjectId property.</param>
        /// <param name="affectedTask">The Task that is subject to the event.</param>
        public TaskEventArgs(Task affectedTask)
        {
            Task = affectedTask;
        }

        /// <summary>
        /// The Id of the Task that is affected by the event
        /// </summary>       
        public string TaskId { get { return this.Task.Id; } }

        /// <summary>
        /// The Task that is subject to the event.
        /// </summary>
        public Task Task { get; set; }
    }


    /// <summary>
    /// EventArgs for events concering Projects that contain information to identify the Project that is subject to the event.
    /// </summary>
    public class ProjectEventArgs : EventArgs
    {
        /// <summary>
        /// Initializes a new instance of ProjectEventArgs
        /// </summary>
        /// <param name="projectId">The value of the <see cref="ProjectId"/> property.</param>
        public ProjectEventArgs(string projectId)
        {
            this.ProjectId = projectId;
        }

        /// <summary>
        /// The Id of the Project.
        /// </summary>
        public string ProjectId { get; set; }
    }

    ///// <summary>
    ///// EventArgs for PropertyUpdated events.
    ///// </summary>
    //public class PropertyChangedEventArgs : EventArgs
    //{
    //    /// <summary>
    //    /// Initializes a new instance of PropertyChangedEventArgs.
    //    /// </summary>
    //    /// <param name="propertyName">The name of the property that has changed.</param>
    //    public PropertyChangedEventArgs(string propertyName, object oldValue)
    //    {
    //        PropertyName = propertyName;
    //        this.OldValue = oldValue;
    //    }

    //    /// <summary>
    //    /// The name of the property that has changed.
    //    /// </summary>
    //    public string PropertyName { get; protected set; }

    //    public object OldValue { get; protected set; }
    //}


    /// <summary>
    /// EventArgs for IdChanged events.
    /// </summary>
    public class IdChangedEventArgs : EventArgs
    {
        /// <summary>
        /// Initializes a new instance of IdChangedEventArgs.
        /// </summary>
        /// <param name="propertyName">The name of the property that has changed.</param>
        public IdChangedEventArgs(string _oldId)
        {
            OldId = _oldId;
        }

        public string OldId { get; protected set; }
    }

#if !SILVERLIGHT
    public class SyncConflictEventArgs : EventArgs
    {
        public List<object> Items { get; set; }

        public object resolvedItem;        

        public bool Resolved { get; set; }
    }

#endif

    public class LoginRequiredEventArgs : EventArgs
    {
        public bool Handled { get; set; }       

        public string Email { get; set; }

        public SecureString Password { get; set; }
    }


    public class ErrorEventArgsV1 : EventArgs
    {
        public string Error { get; set; }
    }


    public class ErrorEventArgsV2 : EventArgs
    {
        [DebuggerStepThrough()]
        public ErrorEventArgsV2() 
        {
            Handled = false;
        }


        [DebuggerStepThrough()]
        public ErrorEventArgsV2(int errorCode, string errorMessage):this()
        {
            this.ErrorCode = errorCode;
            this.ErrorMessage = errorMessage;
        }

        public int ErrorCode { get; set; }

        public string ErrorMessage { get; set; }


        public bool Handled { get; set; }

        [DebuggerStepThrough()]
        public override string ToString()
        {
            return String.Format("Code: {0}, Message: {1}, Handled: {2}", ErrorCode, ErrorMessage, Handled);
        }
    }
}
